package com.hbnu.system.controller;

import com.hbnu.system.core.base.Rest;
import com.hbnu.system.model.entity.CooperaForm;
import com.hbnu.system.service.CooperaFormService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/CooperaForm")
@Api(tags = "纵向-合作形式模块")
public class CooperaFormController {
    @Autowired
    private CooperaFormService cooperaFormService;

    @ApiOperation("合作形式添加")
    @PostMapping("/addCooperaForm")
    public Rest<Boolean> addCooperaForm(@RequestBody CooperaForm cooperaForm){
        boolean add = cooperaFormService.addCooperaForm(cooperaForm);
        return add ? Rest.success():Rest.failed();
    }

    @ApiOperation("获取合作形式列表")
    @GetMapping("/getCooperaForm")
    public Rest<List<CooperaForm>> getCooperaForms(){
        List<CooperaForm> projectcateList = cooperaFormService.getCooperaFormList();
        return Rest.success(projectcateList);
    }

    @ApiOperation("合作形式-修改")
    @PostMapping("/updateCooperaForm")
    public Rest<Boolean> updateCooperaForm(@RequestBody CooperaForm cooperaForm){
        boolean update = cooperaFormService.updateCooperaForm(cooperaForm);
        return update ? Rest.success() : Rest.failed();
    }

    @ApiOperation("合作形式-删除")
    @GetMapping("/deleteCooperaForm")
    public Rest<Boolean> deleteCooperaForm(String ID){
        boolean delete = cooperaFormService.deleteCooperaForm(ID);
        return delete ? Rest.success() : Rest.failed();
    }

}
